<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:redirect="http://xml.apache.org/xalan/redirect" extension-element-prefixes="redirect"
	version="1.0">
	<xsl:output method="text" />
	<xsl:variable name="positiveFileName">positive.txt</xsl:variable>
	<xsl:variable name="negativeFileName">negative.txt</xsl:variable>
	<xsl:template match="/">
		<xsl:apply-templates />
	</xsl:template>
	<xsl:template match="root">
		<xsl:apply-templates />
	</xsl:template>
	<xsl:template match="tweet[normalize-space(polarity/text())='POSITIVE']">
        <xsl:message>POSITIVE</xsl:message>
		<xsl:variable name="filename" select="concat('D:\home\andre\twitter\workspace_twitter\TwitterCorpus\output\',$positiveFileName)" />
		<redirect:open append="true" file="{$filename}"/>
		<redirect:write file="{$filename}">
           <xsl:text>polarity.</xsl:text><xsl:value-of select="normalize-space(polarity/text())" /><xsl:text>,"</xsl:text><xsl:value-of select="normalize-space(text/text())" /><xsl:text>"</xsl:text><xsl:text>&#10;</xsl:text>
        </redirect:write>
		<redirect:close file="{$filename}"/>
	</xsl:template>
	<xsl:template match="tweet[normalize-space(polarity/text())='NEGATIVE']">
        <xsl:message>NEGATIVE</xsl:message>
        <xsl:variable name="filename" select="concat('D:\home\andre\twitter\workspace_twitter\TwitterCorpus\output\',$negativeFileName)" />
        <redirect:open append="true" file="{$filename}"/>
        <redirect:write file="{$filename}">
            <xsl:text>polarity.</xsl:text><xsl:value-of select="normalize-space(polarity/text())" /><xsl:text>,"</xsl:text><xsl:value-of select="normalize-space(text/text())" /><xsl:text>"</xsl:text><xsl:text>&#10;</xsl:text>
        </redirect:write>
        <redirect:close file="{$filename}"/>
    </xsl:template>
</xsl:stylesheet>